import sysApi from '@/api/declaration/sysApi'
import httpRequest from "@/config/axios/httpRequest"
import {  
  CreateDictTypeReq, 
  CreateDictTypeResp, 
  DeleteDictTypeReq, 
  DeleteDictTypeResp, 
  ExportDictTypeReq, 
  QueryDictTypePageReq, 
  QueryDictTypePageResp, 
  QueryDictTypeResp, 
  UpdateDictTypeReq, 
  UpdateDictTypeResp 
} from "@/models/system/DataDictionaryModel"

export type DictTypeVO = {
  id: number | undefined
  name: string
  type: string
  status: number
  remark: string
  createTime: Date
}

// 查询字典列表
export const getDictTypePage = async (params: QueryDictTypePageReq) => {
  return await httpRequest.get<QueryDictTypePageResp>(sysApi.QueryDictDataTypePage,{params})
}

// 查询字典详情
export const getDictType = async (id: number) => {
  return await httpRequest.get<QueryDictTypeResp>(sysApi.QueryDictDataType,{ params: {ID: id}})
}

// 新增字典
export const createDictType = async (data: CreateDictTypeReq) => {
  return await httpRequest.post<CreateDictTypeResp>(sysApi.CreateDictDataType, data)
}

// 修改字典
export const updateDictType = async (data: UpdateDictTypeReq) => {
  return await httpRequest.put<UpdateDictTypeResp>(sysApi.UpdateDictDataType, data)
}

// 删除字典
export const deleteDictType = async (params:DeleteDictTypeReq) => {
  return await httpRequest.delete<DeleteDictTypeResp>(sysApi.DeleteDictDataType,{ params })
}
// 导出字典类型
export const exportDictType = async (params:ExportDictTypeReq) => {
  return await httpRequest.download(sysApi.DownloadDictDataType, { params, responseType: 'blob' })
}
